{"ast":null,"code":"import _slicedToArray from\"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/slicedToArray.js\";import React from'react';import{Context}from\"../../../index\";import{useForm,Controller,useFormState}from'react-hook-form';import Typography from'@mui/material/Typography';import TextField from'@mui/material/TextField';import Button from\"../../../components/Button\";import{emailValidation,nicknameValidation}from'../../validation';import MailOutlineIcon from'@mui/icons-material/MailOutline';import AlternateEmailOutlinedIcon from'@mui/icons-material/AlternateEmailOutlined';import styles from'../../Form.module.scss';import{jsx as _jsx}from\"react/jsx-runtime\";import{jsxs as _jsxs}from\"react/jsx-runtime\";var PasswordForm=function PasswordForm(props){var _React$useContext=React.useContext(Context),store=_React$useContext.store;var _useForm=useForm(),handleSubmit=_useForm.handleSubmit,control=_useForm.control;var _useFormState=useFormState({control:control}),errors=_useFormState.errors;var _React$useState=React.useState({registration:'registration',login:'login'}),_React$useState2=_slicedToArray(_React$useState,1),data=_React$useState2[0];var onSubmit=function onSubmit(data){store.setIsError(false);store.forgotPassword(data);if(props.updateInfo){props.updateInfo(true);}};return/*#__PURE__*/_jsxs(\"div\",{className:styles.authForm,children:[/*#__PURE__*/_jsx(Typography,{variant:\"h4\",component:\"div\",className:styles.authFormTitle,children:\"\\u0412\\u043E\\u0441\\u0441\\u0442\\u0430\\u043D\\u043E\\u0432\\u043B\\u0435\\u043D\\u0438\\u0435\"}),/*#__PURE__*/_jsxs(\"form\",{className:styles.authForm__form,onSubmit:handleSubmit(onSubmit),children:[/*#__PURE__*/_jsx(Controller,{control:control,name:\"email\",rules:emailValidation,render:function render(_ref){var _errors$email,_errors$email2;var field=_ref.field;return/*#__PURE__*/_jsx(TextField,{label:\"\\u042D\\u043B. \\u0430\\u0434\\u0440\\u0435\\u0441\",InputProps:{endAdornment:/*#__PURE__*/_jsx(MailOutlineIcon,{className:styles.formIcon})},onChange:function onChange(e){return field.onChange(e);},value:field.value||'',fullWidth:true,size:\"small\",margin:\"normal\",type:\"email\",error:!!((_errors$email=errors.email)!==null&&_errors$email!==void 0&&_errors$email.message),helperText:(_errors$email2=errors.email)===null||_errors$email2===void 0?void 0:_errors$email2.message});}}),/*#__PURE__*/_jsx(Controller,{control:control,name:\"nickname\",rules:nicknameValidation,render:function render(_ref2){var _errors$nickname,_errors$nickname2;var field=_ref2.field;return/*#__PURE__*/_jsx(TextField,{label:\"\\u041F\\u0441\\u0435\\u0432\\u0434\\u043E\\u043D\\u0438\\u043C\",InputProps:{endAdornment:/*#__PURE__*/_jsx(AlternateEmailOutlinedIcon,{className:styles.formIcon})},onChange:function onChange(e){return field.onChange(e);},value:field.value||'',fullWidth:true,size:\"small\",margin:\"normal\",type:\"text\",helperText:(_errors$nickname=errors.nickname)===null||_errors$nickname===void 0?void 0:_errors$nickname.message,error:!!((_errors$nickname2=errors.nickname)!==null&&_errors$nickname2!==void 0&&_errors$nickname2.message)});}}),/*#__PURE__*/_jsx(Button,{text:'Восстановить'})]}),/*#__PURE__*/_jsxs(\"div\",{className:styles.authForm__footer,children:[/*#__PURE__*/_jsx(Typography,{variant:\"subtitle1\",component:\"span\",className:styles.link,onClick:function onClick(){if(props.updateInfo){props.updateInfo(false);}props.updateData(data.login);store.setIsError(false);},children:\"\\u0412\\u043E\\u0439\\u0442\\u0438\"}),/*#__PURE__*/_jsx(Typography,{variant:\"subtitle1\",component:\"span\",className:styles.link,onClick:function onClick(){if(props.updateInfo){props.updateInfo(false);}store.setIsError(false);props.updateData(data.registration);},children:\"\\u0417\\u0430\\u0440\\u0435\\u0433\\u0438\\u0441\\u0442\\u0440\\u0438\\u0440\\u043E\\u0432\\u0430\\u0442\\u044C\\u0441\\u044F\"})]})]});};export default PasswordForm;","map":{"version":3,"names":["React","Context","useForm","Controller","useFormState","Typography","TextField","Button","emailValidation","nicknameValidation","MailOutlineIcon","AlternateEmailOutlinedIcon","styles","PasswordForm","props","useContext","store","handleSubmit","control","errors","useState","registration","login","data","onSubmit","setIsError","forgotPassword","updateInfo","authForm","authFormTitle","authForm__form","field","endAdornment","formIcon","e","onChange","value","email","message","nickname","authForm__footer","link","updateData"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/src/modules/PasswordForm/components/PasswordForm.tsx"],"sourcesContent":["import React from 'react';\nimport {Context} from \"../../../index\";\nimport {useForm, Controller, SubmitHandler, useFormState} from 'react-hook-form';\nimport ForgotPasswordRequest from \"../../../models/request/ForgotPasswordRequest\";\nimport Typography from '@mui/material/Typography';\nimport TextField from '@mui/material/TextField';\nimport Button from \"../../../components/Button\";\nimport {emailValidation, nicknameValidation} from  '../../validation';\nimport MailOutlineIcon from '@mui/icons-material/MailOutline';\nimport AlternateEmailOutlinedIcon from '@mui/icons-material/AlternateEmailOutlined';\nimport {AuthProps} from \"../../../models/props/AuthProps\";\nimport styles from '../../Form.module.scss';\n\nconst PasswordForm: React.FC<AuthProps> = (props) => {\n    const {store} = React.useContext(Context);\n    const {handleSubmit, control} = useForm<ForgotPasswordRequest>();\n    const {errors} = useFormState({control});\n    const [data] = React.useState({\n            registration: 'registration',\n            login: 'login'\n        }\n    );\n\n    const onSubmit: SubmitHandler<ForgotPasswordRequest> = (data) => {\n        store.setIsError(false);\n        store.forgotPassword(data);\n        if (props.updateInfo) {\n            props.updateInfo(true);\n        }\n    };\n\n    return (\n        <div className={styles.authForm}>\n            <Typography variant=\"h4\" component=\"div\" className={styles.authFormTitle}>\n                Восстановление\n            </Typography>\n            <form className={styles.authForm__form} onSubmit={handleSubmit(onSubmit)}>\n                <Controller\n                    control={control}\n                    name=\"email\"\n                    rules={emailValidation}\n                    render={({ field }) => (\n                        <TextField\n                            label=\"Эл. адрес\"\n                            InputProps={{\n                                endAdornment: (\n                                    <MailOutlineIcon className={styles.formIcon}/>\n                                ),\n                            }}\n                            onChange={(e) => field.onChange(e)}\n                            value={field.value || ''}\n                            fullWidth={ true }\n                            size=\"small\"\n                            margin=\"normal\"\n                            type=\"email\"\n                            error={!!errors.email?.message}\n                            helperText={errors.email?.message}\n                        />\n                    )}\n                />\n                <Controller\n                    control={control}\n                    name=\"nickname\"\n                    rules={nicknameValidation}\n                    render={({ field }) => (\n                        <TextField\n                            label=\"Псевдоним\"\n                            InputProps={{\n                                endAdornment: (\n                                    <AlternateEmailOutlinedIcon className={styles.formIcon}/>\n                                ),\n                            }}\n                            onChange={(e) => field.onChange(e)}\n                            value={field.value || ''}\n                            fullWidth={ true }\n                            size=\"small\"\n                            margin=\"normal\"\n                            type=\"text\"\n                            helperText={errors.nickname?.message}\n                            error={!!errors.nickname?.message}\n                        />\n                    )}\n                />\n                <Button text={'Восстановить'} />\n            </form>\n            <div className={styles.authForm__footer}>\n                <Typography variant=\"subtitle1\" component=\"span\" className={styles.link}\n                            onClick = {() => {\n                                if (props.updateInfo) {\n                                    props.updateInfo(false);\n                                }\n                                props.updateData(data.login);\n                                store.setIsError(false)\n                            }}>\n                    Войти\n                </Typography>\n                <Typography variant=\"subtitle1\" component=\"span\" className={styles.link}\n                            onClick = {() => {\n                                if (props.updateInfo) {\n                                    props.updateInfo(false);\n                                }\n                                store.setIsError(false);\n                                props.updateData(data.registration);\n                            }}>\n                    Зарегистрироваться\n                </Typography>\n            </div>\n        </div>\n    );\n}\n\nexport default PasswordForm;"],"mappings":"8IAAA,MAAOA,MAAK,KAAM,OAAO,CACzB,OAAQC,OAAO,KAAO,gBAAgB,CACtC,OAAQC,OAAO,CAAEC,UAAU,CAAiBC,YAAY,KAAO,iBAAiB,CAEhF,MAAOC,WAAU,KAAM,0BAA0B,CACjD,MAAOC,UAAS,KAAM,yBAAyB,CAC/C,MAAOC,OAAM,KAAM,4BAA4B,CAC/C,OAAQC,eAAe,CAAEC,kBAAkB,KAAQ,kBAAkB,CACrE,MAAOC,gBAAe,KAAM,iCAAiC,CAC7D,MAAOC,2BAA0B,KAAM,4CAA4C,CAEnF,MAAOC,OAAM,KAAM,wBAAwB,CAAC,wFAE5C,GAAMC,aAAiC,CAAG,QAApCA,aAAiC,CAAIC,KAAK,CAAK,CACjD,sBAAgBd,KAAK,CAAC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